<%--
  Created by IntelliJ IDEA.
  User: fengdefangxiang
  Date: 2022/1/16
  Time: 23:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%@ include file="/web/header.jsp"%>
</head>
<body>
<fieldset class="layui-elem-field" style="margin: 10px">
    <legend>添加</legend>
    <div class="layui-field-box">
        <form class="layui-form layui-form-pane" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="code" required lay-verify="required" placeholder="请输入编号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" required lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">电话</label>
                <div class="layui-input-inline">
                    <input type="text" name="tel" required placeholder="请输入电话" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="button" value="确定" class="layui-btn" lay-submit lay-filter="add">
                    <input type="reset" class="layui-btn layui-btn-primary">
                    <input type="button" value="关闭" class="layui-btn" onclick="layerClose()">
                </div>
            </div>
            <input type="hidden" name="action" value="add">
        </form>
    </div>
</fieldset>
<script type="text/javascript">
    formOnSubmit('add','/DepartmentServlet','text',function (data){
        console.log(data)
        if (data == 1) {
            layer.msg("添加成功",layerClose); // 添加成功后要加回调函数，因为成功后要关闭
        } else if (data == "repeat") {
            layer.msg("编号重复");
        } else {
            layer.msg("添加失败");
        }
    })
</script>
</body>
</html>
